<?php
class IcqHTTPWebService extends HTTPWebService {

    function onMethodCall($strClassName, $strMethodName, $arRequest) {
        if ("IcqHTTPWebService" == $strClassName) {
            if ("activate" == $strMethodName) {
                if (isset($arRequest['uin']) && isset($arRequest['password'])) {

                    // Start ICQ node's thread
                    $IcqContext = new IcqContext($arRequest['uin'], $arRequest['password']);
                    $IcqNode = new IcqNode($IcqContext);
                    $IcqNode->activate();
                    unset($IcqNode);
                    unset($IcqContext);
                }
            } else if ("read" == $strMethodName) {
                if (isset($arRequest['uin']) && isset($arRequest['password'])) {

                    // Read ICQ node
                    $IcqContext = new IcqContext($arRequest['uin'], $arRequest['password']);
                    $IcqNode = new IcqNode($IcqContext);
                    $result = $IcqNode->read();
                    unset($IcqNode);
                    unset($IcqContext);
                    return $result;
                }
            } else if ("write" == $strMethodName) {
                if (isset($arRequest['uin']) && isset($arRequest['password'])) {

                    // Write ICQ node
                    $IcqContext = new IcqContext($arRequest['uin'], $arRequest['password']);
                    $IcqNode = new IcqNode($IcqContext);
                    $result = $IcqNode->write($arRequest);
                    unset($IcqNode);
                    unset($IcqContext);
                    return $result;
                }
            }
        }
    }
}
?>